package com.ucampus.dao;

import com.ucampus.entity.SearchResult;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface oS_searchMapper {

    @Select("""
        SELECT 'food' AS type, id, name, img, address AS details 
        FROM foods 
        WHERE name LIKE CONCAT('%', #{keyword}, '%') 
           OR address LIKE CONCAT('%', #{keyword}, '%')
        UNION
        SELECT 'view' AS type, id, name, img, content AS details 
        FROM outsideviews 
        WHERE name LIKE CONCAT('%', #{keyword}, '%') 
           OR content LIKE CONCAT('%', #{keyword}, '%')
        """)
    List<SearchResult> searchByKeyword(@Param("keyword") String keyword);
}
